<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.8.0">
  <!-- Google AdSense start -->
	<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
  (adsbygoogle = window.adsbygoogle || []).push({
    google_ad_client: "ca-pub-6877569709040311",
    enable_page_level_ads: true
  });
</script>
  <!-- Google AdSense end -->
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">



  
  
    
    
  <script src="/lib/pace/pace.min.js?v=1.0.2"></script>
  <link href="/lib/pace/pace-theme-minimal.min.css?v=1.0.2" rel="stylesheet">







<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">





  <script>
  (function(i,s,o,g,r,a,m){i["DaoVoiceObject"]=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;a.charset="utf-8";m.parentNode.insertBefore(a,m)})(window,document,"script",('https:' == document.location.protocol ? 'https:' : 'http:') + "//widget.daovoice.io/widget/0f81ff2f.js","daovoice")
  daovoice('init', {
      app_id: "46887a48"
    });
  daovoice('update');
  </script>














  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/tao.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/tao.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/tao.png?v=5.1.4">






  <meta name="keywords" content="打卡,">





  <link rel="alternate" href="/atom.xml" title="月小水长的个人博客" type="application/atom+xml">






<meta name="description" content="这学期受某人所托，给学院做了一款打卡小程序。其效果如下： 一个类似论坛的社区，可发帖、评论、回复。     打卡可换算积分，一天只能打卡一次，且有今日打卡排行榜实时展示。    跑步也可换算积分，换算的规则男女有别。    这个小程序的上线成本比较高，需要营业执照，还有因为论坛的存在，上线之后还需要工信部的备案资质，否则不予更新代码，所以我已经停止对它的维护了。开源这个项目的代码： github地">
<meta name="keywords" content="打卡">
<meta property="og:type" content="article">
<meta property="og:title" content="打卡微信小程序">
<meta property="og:url" content="https://inspurer.github.io/2018/11/07/打卡微信小程序/index.html">
<meta property="og:site_name" content="月小水长的个人博客">
<meta property="og:description" content="这学期受某人所托，给学院做了一款打卡小程序。其效果如下： 一个类似论坛的社区，可发帖、评论、回复。     打卡可换算积分，一天只能打卡一次，且有今日打卡排行榜实时展示。    跑步也可换算积分，换算的规则男女有别。    这个小程序的上线成本比较高，需要营业执照，还有因为论坛的存在，上线之后还需要工信部的备案资质，否则不予更新代码，所以我已经停止对它的维护了。开源这个项目的代码： github地">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="https://s2.ax1x.com/2019/04/10/AT4LKf.jpg">
<meta property="og:image" content="https://s2.ax1x.com/2019/04/10/AT4z5j.jpg">
<meta property="og:updated_time" content="2019-04-10T10:50:44.749Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="打卡微信小程序">
<meta name="twitter:description" content="这学期受某人所托，给学院做了一款打卡小程序。其效果如下： 一个类似论坛的社区，可发帖、评论、回复。     打卡可换算积分，一天只能打卡一次，且有今日打卡排行榜实时展示。    跑步也可换算积分，换算的规则男女有别。    这个小程序的上线成本比较高，需要营业执照，还有因为论坛的存在，上线之后还需要工信部的备案资质，否则不予更新代码，所以我已经停止对它的维护了。开源这个项目的代码： github地">
<meta name="twitter:image" content="https://s2.ax1x.com/2019/04/10/AT4LKf.jpg">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":true,"scrollpercent":true,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>

<script>
    (function(){
        if(''){
            if (prompt('请输入文章密码') !== ''){
                alert('密码错误！');
                history.back();
            }
        }
    })();
</script>




  <link rel="canonical" href="https://inspurer.github.io/2018/11/07/打卡微信小程序/">





  <title>打卡微信小程序 | 月小水长的个人博客</title>
  








</head>



   <canvas class="fireworks" style="position: fixed;left: 0;top: 0;z-index: 1; pointer-events: none;"></canvas> 
   <script type="text/javascript" src="//cdn.bootcss.com/animejs/2.2.0/anime.min.js"></script> 
   <script type="text/javascript" src="/js/src/fireworks.js"></script>


<script type="text/javascript" src="//cdn.bootcss.com/canvas-nest.js/1.0.0/canvas-nest.min.js"></script>

<body itemscope="" itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>
	
	<a href="https://github.com/inspurer" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewbox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"/><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"/><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"/></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>

    <header id="header" class="header" itemscope="" itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">月小水长的个人博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">微信公众号@月小水长</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br>
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-welfare">
          <a href="/welfare/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-coffee"></i> <br>
            
            福利
          </a>
        </li>
      
        
        <li class="menu-item menu-item-message">
          <a href="/message/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-comment"></i> <br>
            
            留言
          </a>
        </li>
      
        
        <li class="menu-item menu-item-thank">
          <a href="/thank/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-heartbeat"></i> <br>
            
            致谢
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br>
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off" placeholder="搜索..." spellcheck="false" type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>



    </div>
  
</nav>

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
  (adsbygoogle = window.adsbygoogle || []).push({
    google_ad_client: "ca-pub-6877569709040311",
    enable_page_level_ads: true
  });
</script>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope="" itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://inspurer.github.io/2018/11/07/打卡微信小程序/">

    <span hidden itemprop="author" itemscope="" itemtype="http://schema.org/Person">
      <meta itemprop="name" content="月小水长">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope="" itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="月小水长的个人博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">打卡微信小程序</h1>
        

        <div class="post-meta">
			

          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于&#58;</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-11-07T19:41:19+08:00">
                2018-11-07
              </time>
            

            
              <span class="post-meta-divider">|</span>
            

            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-check-o"></i>
              </span>
              
                <span class="post-meta-item-text">更新于&#58;</span>
              
              <time title="更新于" itemprop="dateModified" datetime="2019-04-10T18:50:44+08:00">
                2019-04-10
              </time>
            
          </span>
		  
		  

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
                               
                <span class="post-meta-item-text">分类于&#58;</span>
              
              
                <span itemprop="about" itemscope="" itemtype="http://schema.org/Thing">
                  <a href="/categories/小程序/" itemprop="url" rel="index">
                    <span itemprop="name">小程序</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
				<span class="post-meta-item-text">评论数&#58;</span>
                <a href="/2018/11/07/打卡微信小程序/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count valine-comment-count" data-xid="/2018/11/07/打卡微信小程序/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          
             <span id="/2018/11/07/打卡微信小程序/" class="leancloud_visitors" data-flag-title="打卡微信小程序">
               <span class="post-meta-divider">|</span>
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               
                 <span class="post-meta-item-text">阅读次数&#58;</span>
               
                 <span class="leancloud-visitors-count"></span>
             </span>
          

          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  1.4k字
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  7分钟
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>这学期受某人所托，给学院做了一款打卡小程序。其效果如下：</p>
<pre><code>一个类似论坛的社区，可发帖、评论、回复。    
打卡可换算积分，一天只能打卡一次，且有今日打卡排行榜实时展示。   
跑步也可换算积分，换算的规则男女有别。   
</code></pre><p><img src="https://s2.ax1x.com/2019/04/10/AT4LKf.jpg" alt=""><br>这个小程序的上线成本比较高，需要营业执照，还有因为论坛的存在，上线之后还需要工信部的备案资质，否则不予更新代码，所以我已经停止对它的维护了。开源这个项目的代码： <a href="https://github.com/inspurer/CampusPunchcard" target="_blank" rel="noopener">github地址</a>,欢迎star、fork!!!    </p>
<p>今天我主要讲述其中的打卡部分的制作,为了后期维护，我已经单独把这部分做成一个小程序，欢迎体验。</p>
<center><img src="https://s2.ax1x.com/2019/04/10/AT4z5j.jpg"></center>

<p>talk  is cheap,show the code.</p>
<h2 id="核心代码"><a href="#核心代码" class="headerlink" title="核心代码"></a>核心代码</h2><h3 id="punch-js"><a href="#punch-js" class="headerlink" title="punch.js"></a>punch.js</h3><pre><code>var app = getApp();
var date;
var allowlog = 1;
var Bmob = require(&apos;../../utils/bmob.js&apos;);
Page({

  /**
   * 页面的初始数据
   */
  data: {
   newList: [],
  },

  btn_click: function(e){
    if (allowlog == 1){
      allowlog = 0;
      wx.getStorage({
        key: &apos;user_id&apos;,
        success: function (res) {
          var user_id = new Bmob.User();
          user_id.id = res.data;
          wx.getStorage({
            key: &apos;my_nick&apos;,
            success: function (ress) {
              var mydate = new Date();
              var year = mydate.getFullYear();
              var month = mydate.getMonth() + 1;
              var day = mydate.getDate();
              var date = year + &quot;年&quot; + month + &quot;月&quot; + day + &quot;日&quot;;
              var hour = mydate.getHours(); //获取当前小时数(0-23)
              var minute = mydate.getMinutes(); //获取当前分钟数(0-59)
              var second = mydate.getSeconds(); //获取当前秒数(0-59)
              var time = hour + &quot;时&quot; + minute + &quot;分&quot; + second + &quot;秒&quot;;
              var avatar = wx.getStorageSync(&quot;my_avatar&quot;);
              var Punch = Bmob.Object.extend(&quot;punch&quot;);
              var punch = new Punch();
              var me = ress.data;
              var query = new Bmob.Query(Punch);
              query.equalTo(&quot;nickname&quot;, me);
              query.equalTo(&quot;date&quot;, date);
              // 查询所有数据
              query.find({
                success: function (results) {
                  console.log(&quot;共查询到 &quot; + results.length + &quot; 条记录&quot;);
                  if (results.length == 0) {
                    if (hour &gt;= 6) {
                      if (hour &lt; 8) {
                        var intger;
                        if (hour &lt; 7) {
                          if (minute &lt;= 20) {
                            intger = 3;
                          }
                          else if (minute &lt;= 40) {
                            intger = 2.5;
                          }
                          else {
                            intger = 2;
                          }
                        }
                        else if (hour &lt; 8) {
                          if (minute &lt;= 20) {
                            intger = 1.5;
                          }
                          else if (minute &lt;= 40) {
                            intger = 1;
                          }
                          else {
                            intger = 0.5;
                          }
                        }
                        wx.showToast({
                          title: &apos;打卡成功+&apos; + intger + &quot;分&quot;,
                          icon: &apos;success&apos;
                        })
                        wx.getStorage({
                          key: &apos;my_username&apos;,
                          success: function (ress) {
                            if (ress.data) {
                              var my_username = ress.data;
                              wx.getStorage({
                                key: &apos;user_openid&apos;,
                                success: function (openid) {
                                  var openid = openid.data;
                                  var user = Bmob.User.logIn(my_username, openid, {
                                    success: function (users) {
                                      var score = users.get(&apos;score&apos;);
                                      score = score + intger;
                                      users.set(&apos;score&apos;, score);
                                      users.save(null, {
                                        success: function (user) {
                                        },
                                        error: function (error) {
                                          console.log(error)
                                        }
                                      });
                                    }
                                  });
                                }, function(error) {
                                  console.log(error);
                                }
                              })
                            }

                          }
                        })
                        punch.set(&apos;nickname&apos;, me);
                        punch.set(&apos;user_id&apos;, user_id);
                        punch.set(&apos;date&apos;, date);
                        punch.set(&apos;avatar&apos;, avatar)
                        punch.set(&apos;time&apos;, time);
                        console.log(me, user_id);
                        punch.save(null, {
                          success: function (result) {
                            console.log(&apos;success&apos;);
                            allowlog = 1;

                          },
                          error: function (result, error) {
                            console.log(result, error, &quot;failure&quot;)
                          }
                        })
                      }
                      else {
                        wx.showToast({
                          title: &apos;已过打卡时间&apos;,
                          icon: &apos;loading&apos;
                        })
                      }
                    }
                    else {
                      wx.showToast({
                        title: &apos;还没到打卡时间&apos;,
                        icon: &apos;loading&apos;
                      })
                    }


                  }
                  else {
                    allowlog = 1;
                    wx.showToast({
                      title: &apos;重复打卡&apos;,
                      icon: &apos;loading&apos;
                    })
                  }
                },
                error: function (error) {
                  console.log(&quot;查询失败&quot;);
                }
              });
            }
          })

        },
      })
    }
    else{
      wx.showToast({
        title: &apos;点的太快了&apos;,
        icon: &apos;loading&apos;
      })
    }

  },
  tempData: function () {
    var that = this;
    var Punch = Bmob.Object.extend(&quot;punch&quot;);
    var query = new Bmob.Query(Punch);
    var mydate = new Date();
    var year = mydate.getFullYear();
    var month = mydate.getMonth() + 1;
    var day = mydate.getDate();
    var date = year + &quot;年&quot; + month + &quot;月&quot; + day + &quot;日&quot;;
    query.equalTo(&quot;date&quot;, date);
    query.limit(100);
    var results = [];
    query.find({
      success: function (result) {
        for (var i = 0; i &lt; result.length; i++) {
          console.log(&apos;共有打卡记录:&apos;, result.length)
          var object = result[i];
          object.set(&apos;time&apos;, object.createdAt.substring(11, 19));
          object.set(&apos;rank&apos;, i + 1);
          results[i] = object;
        }
        console.log(results);
        that.setData({
          list: results
        });
      }
    })

  },
  onLoad: function () {
    this.tempData();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },


  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.tempData();
    wx.stopPullDownRefresh();
  },

  onShareAppMessage: function () {
    return {
      title: &apos;快来打卡赢积分&apos;,
      imageUrl: &apos;../../static/images/tao.png&apos;
    }
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  }
})
</code></pre><h3 id="pun-wxml"><a href="#pun-wxml" class="headerlink" title="pun.wxml"></a>pun.wxml</h3><pre><code>&lt;view class=&quot;title&quot;&gt;今日打卡榜&lt;/view&gt;
&lt;view class=&quot;item-box&quot;&gt;
  &lt;view class=&quot;items&quot;&gt;
    &lt;view wx:for=&quot;{{list}}&quot;  wx:key=&quot;{{index}}&quot;  class=&quot;item&quot;&gt;

      &lt;view data-index=&quot;{{index}}&quot; class=&quot;inner txt&quot;&gt;
      &lt;i&gt;{{item.rank}}&lt;/i&gt;
      &lt;image class=&quot;item-icon&quot; mode=&quot;widthFix&quot; src=&quot;{{item.avatar}}&quot;&gt;&lt;/image&gt;
       &lt;i&gt; {{item.nickname}}&lt;/i&gt;
      &lt;span class=&quot;item-data&quot;&gt;

       &lt;i class=&quot;rankpace&quot;&gt; 打卡时间:{{item.time}}&lt;/i&gt;
        &lt;!-- &lt;span class=&quot;rankxin&quot;&gt;{{item.xin}}&lt;/span&gt; --&gt;
      &lt;/span&gt;

      &lt;/view&gt;

    &lt;/view&gt;
  &lt;/view&gt;
&lt;/view&gt;&lt;!--pages/ranking/ranking.wxml--&gt;

&lt;button  class=&quot;circle&quot; bindtap=&quot;btn_click&quot;&gt;开始打卡&lt;/button&gt;
</code></pre><h3 id="punch-css"><a href="#punch-css" class="headerlink" title="punch.css"></a>punch.css</h3><pre><code>page {
  background: #fff;
  padding: 0 0rpx 0;
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  background-size: cover;
  background-image: url(http://bmob-cdn-21956.b0.upaiyun.com/2018/11/08/e16028434063466d80d9d79f281ce145.jpg);
}
/* pages/leftSwiperDel/index.wxss */
view{
    box-sizing: border-box;
}
.item-box{
    width: 700rpx;
    height: 10rpx;
    margin: 0 auto;
    padding:40rpx 0;
}
.title{
  margin-top: 12px;
  font-size: 20px;
  height: 12px;
  text-align: center;  
}
.items{
    width: 100%;
}
.item{
    position: relative;
    border-top: 2rpx solid #eee;
    height: 120rpx;
    line-height: 120rpx;
    overflow: hidden;

}


.item:last-child{
    border-bottom: 2rpx solid #eee;
}
.inner{
    position: absolute;
    top:0;
}
.inner.txt{
    background-color: #fff;
    width: 100%;
    z-index: 5;
    padding:0 10rpx;
    transition: left 0.2s ease-in-out;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}

.item-icon{
    width: 64rpx;
    height: 64rpx;
    vertical-align: middle;
    margin-right: 16rpx;
    margin-left:13px;
    border-radius:50%;

}

.item-data{
  float: right;
  margin-right:5%;}

.rankpace{
  color: #87CEFA;
}
.circle{
    right: 35px;
    bottom: 35px;         
    width: 110px;
    background-color: #87CEFA;
    height: 110px;
    padding-top: 28px;
    color: white;
    background-size: cover;
    position: fixed;
    z-index: 9999;
    font-size: 20px;
    text-align: center;
    border: 0 solid #ffffff;
    border-radius: 500px;
    box-shadow: 4px 1px 1px #cccccc;
}
</code></pre><h2 id="后话"><a href="#后话" class="headerlink" title="后话"></a>后话</h2><h3 id="本小程序已上线，欢迎体验。"><a href="#本小程序已上线，欢迎体验。" class="headerlink" title="本小程序已上线，欢迎体验。"></a>本小程序已上线，欢迎体验。</h3><p>可以扫描最上方的小程序码，也可以在微信搜索<code>一见打卡</code></p>
<h3 id="此小程序参考了我以前的代码仓库-https-github-com-inspurer-CampusPunchcard欢迎star-fork"><a href="#此小程序参考了我以前的代码仓库-https-github-com-inspurer-CampusPunchcard欢迎star-fork" class="headerlink" title="此小程序参考了我以前的代码仓库:https://github.com/inspurer/CampusPunchcard欢迎star,fork"></a>此小程序参考了我以前的代码仓库:<a href="https://github.com/inspurer/CampusPunchcard" target="_blank" rel="noopener">https://github.com/inspurer/CampusPunchcard</a>欢迎star,fork</h3><h3 id="如果你也想开发一款这样的小程序，从代码到上线，欢迎联系2391527690-qq-com-同时欢迎关注微信公众号-月小水长"><a href="#如果你也想开发一款这样的小程序，从代码到上线，欢迎联系2391527690-qq-com-同时欢迎关注微信公众号-月小水长" class="headerlink" title="如果你也想开发一款这样的小程序，从代码到上线，欢迎联系2391527690@qq.com,同时欢迎关注微信公众号: 月小水长"></a>如果你也想开发一款这样的小程序，从代码到上线，欢迎联系<a href="mailto:2391527690@qq.com" target="_blank" rel="noopener">2391527690@qq.com</a>,同时欢迎关注微信公众号: 月小水长</h3>
      
    </div>
    
    
    
	<div>
      
        
<div class="my_post_copyright">
  <script src="//cdn.bootcss.com/clipboard.js/1.5.10/clipboard.min.js"></script>

  <!-- JS库 sweetalert 可修改路径 -->
  <script src="https://cdn.bootcss.com/jquery/2.0.0/jquery.min.js"></script>
  <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
  <p><span>本文标题:</span><a href="/2018/11/07/打卡微信小程序/">打卡微信小程序</a></p>
  <p><span>文章作者:</span><a href="/" title="访问 月小水长 的个人博客">月小水长</a></p>
  <p><span>发布时间:</span>2018年11月07日 - 19:11</p>
  <p><span>最后更新:</span>2019年04月10日 - 18:04</p>
  <p><span>原始链接:</span><a href="https://inspurer.github.io" title="1541590879000打卡微信小程序">https://inspurer.github.io/2018/11/07/打卡微信小程序/</a>
    <span class="copy-path" title="点击复制文章链接"><i class="fa fa-clipboard" data-clipboard-text="https://inspurer.github.io/2018/11/07/打卡微信小程序/" aria-label="复制成功！"></i></span>
  </p>
  <p><span>许可协议:</span><i class="fa fa-creative-commons"></i> <a rel="license" href="https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">署名-非商业性使用-禁止演绎 4.0 国际</a> 转载请保留原文链接及作者。</p>  
</div>
<script> 
    var clipboard = new Clipboard('.fa-clipboard');
      $(".fa-clipboard").click(function(){
      clipboard.on('success', function(){
        swal({   
          title: "",   
          text: '复制成功',
          icon: "success", 
          showConfirmButton: true
          });
        });
    });  
</script>

      
	</div>

    

    
      <div>
        <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
  <div>您的赞助将鼓励我继续创作！</div>
  <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
    <span>打赏</span>
  </button>
  <div id="QR" style="display: none;">

    
      <div id="wechat" style="display: inline-block">
        <img id="wechat_qr" src="/images/wechat.png" alt="月小水长 微信支付">
        <p>微信支付</p>
      </div>
    

    
      <div id="alipay" style="display: inline-block">
        <img id="alipay_qr" src="/images/alipay.png" alt="月小水长 支付宝">
        <p>支付宝</p>
      </div>
    

    

  </div>
</div>

      </div>
    

    
	<div>
		
		<div>
    
        <div style="text-align:center;color: #ccc;font-size:14px;">-------------本文结束<i class="fa fa-paw"></i>感谢阅读-------------</div>
    
</div>
		
	</div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/打卡/" rel="tag"><i class="fa fa-tag"></i> 打卡</a>
          
        </div>
      

      
      
        <div class="post-widgets">
        

        

        
          
          <div id="needsharebutton-postbottom">
            <span class="btn">
              <i class="fa fa-share-alt" aria-hidden="true"></i>
            </span>
          </div>
        
        </div>
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2018/09/25/基于opencv人脸识别的员工考勤系统/" rel="next" title="基于opencv人脸识别的员工考勤系统">
                <i class="fa fa-chevron-left"></i> 基于opencv人脸识别的员工考勤系统
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2018/11/10/Windows下操作POP3/" rel="prev" title="Windows下操作POP3">
                Windows下操作POP3 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>


	<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
  (adsbygoogle = window.adsbygoogle || []).push({
    google_ad_client: "ca-pub-6877569709040311",
    enable_page_level_ads: true
  });
</script>

    <div class="post-spread">
      
        
  <script>
    window._bd_share_config = {
      "common": {
        "bdText": "",
        "bdMini": "1",
        "bdMiniList": false,
        "bdPic": ""
      },
      "image": {
        "viewList": ["tsina", "douban", "sqq", "qzone", "weixin", "twi", "fbook"],
        "viewText": "分享到：",
        "viewSize": "16"
      },
      "slide": {
        "bdImg": "5",
        "bdPos": "left",
        "bdTop": "100"
      }
    }
  </script>

<script>
  with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];
</script>

      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
    </div>
  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope="" itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="/images/avatar.jpg" alt="月小水长">
            
              <p class="site-author-name" itemprop="name">月小水长</p>
              <p class="site-description motion-element" itemprop="description">饮冰室主人</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">29</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">9</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/tags/index.html">
                  <span class="site-state-item-count">33</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          
            <div class="feed-link motion-element">
              <a href="/atom.xml" rel="alternate">
                <i class="fa fa-rss"></i>
                RSS
              </a>
            </div>
          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/inspurer" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://blog.csdn.net/ygdxt" target="_blank" title="CSDN">
                      
                        <i class="fa fa-fw fa-crosshairs"></i>CSDN</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://www.jianshu.com/u/1b872cf08f32" target="_blank" title="简书">
                      
                        <i class="fa fa-fw fa-twitter"></i>简书</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://music.163.com/#/playlist?id=490495120" target="_blank" title="云音乐">
                      
                        <i class="fa fa-fw fa-headphones"></i>云音乐</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="mailto:2391527690@qq.com" target="_blank" title="邮箱">
                      
                        <i class="fa fa-fw fa-envelope"></i>邮箱</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://shang.qq.com/wpa/qunwpa?idkey=3abfbe96dfbe8f76a2b72321437fe94b8ba46ba7fb2071943b5830690044e5a0" target="_blank" title="交流群">
                      
                        <i class="fa fa-fw fa-qq"></i>交流群</a>
                  </span>
                
            </div>
          

          
          

          
          
            <div class="links-of-blogroll motion-element links-of-blogroll-inline">
              <div class="links-of-blogroll-title">
                <i class="fa  fa-fw fa-link"></i>
                友情链接
              </div>
              <ul class="links-of-blogroll-list">
                
                  <li class="links-of-blogroll-item">
                    <a href="https://markzxzx.github.io/" title="MarkZXZX" target="_blank">MarkZXZX</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://asdfv1929.github.io/" title="asdfv1929" target="_blank">asdfv1929</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://blog.fujishiro.cn/" title="Otone" target="_blank">Otone</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://52bess.com/" title="zhuimeng" target="_blank">zhuimeng</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="http://www.heanny.cn" title="Heanny Blog" target="_blank">Heanny Blog</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.mochoublog.com/" title="莫愁" target="_blank">莫愁</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://blog.yuki-nagato.com/" title="長門有希" target="_blank">長門有希</a>
                  </li>
                
                  <li class="links-of-blogroll-item">
                    <a href="https://www.fi-forex.com/" title="Forex Trading" target="_blank">Forex Trading</a>
                  </li>
                
              </ul>
            </div>
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#核心代码"><span class="nav-number">1.</span> <span class="nav-text">核心代码</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#punch-js"><span class="nav-number">1.1.</span> <span class="nav-text">punch.js</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#pun-wxml"><span class="nav-number">1.2.</span> <span class="nav-text">pun.wxml</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#punch-css"><span class="nav-number">1.3.</span> <span class="nav-text">punch.css</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#后话"><span class="nav-number">2.</span> <span class="nav-text">后话</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#本小程序已上线，欢迎体验。"><span class="nav-number">2.1.</span> <span class="nav-text">本小程序已上线，欢迎体验。</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#此小程序参考了我以前的代码仓库-https-github-com-inspurer-CampusPunchcard欢迎star-fork"><span class="nav-number">2.2.</span> <span class="nav-text">此小程序参考了我以前的代码仓库:https://github.com/inspurer/CampusPunchcard欢迎star,fork</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#如果你也想开发一款这样的小程序，从代码到上线，欢迎联系2391527690-qq-com-同时欢迎关注微信公众号-月小水长"><span class="nav-number">2.3.</span> <span class="nav-text">如果你也想开发一款这样的小程序，从代码到上线，欢迎联系2391527690@qq.com,同时欢迎关注微信公众号: 月小水长</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      
        <div class="back-to-top">
          <i class="fa fa-arrow-up"></i>
          
            <span id="scrollpercent"><span>0</span>%</span>
          
        </div>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">月小水长</span>

  
</div>


  <div class="powerd by">由 <a class="theme-link" target="_blank" href="https://hexo.io/zh-cn/">Hexo</a> 强力驱动</div>



    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    
      <span class="post-meta-item-text">总字数:</span>
    
    <span title="Site words total count">32.3k</span>
  


  <span class="post-meta-divider">|</span>



	<span>
		<i class="fa fa-eye"></i>
	</span>
<script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
总浏览量:<span id="busuanzi_value_site_pv"></span>

  <span class="post-meta-divider">|</span>

<span><i class="fa fa-user"></i></span>
总访客数:<span id="busuanzi_value_site_uv"></span>


<div class="powerd by">
   
<span id="timeDate">载入天数...</span><span id="times">载入时分秒...</span> 
<script> 
	var now = new Date(); 
	function createtime() { 
		var grt= new Date("06/07/2018 20:15:00");//此处修改你的建站时间或者网站上线时间 
		now.setTime(now.getTime()+250); 
		days = (now - grt ) / 1000 / 60 / 60 / 24; dnum = Math.floor(days); 
		hours = (now - grt ) / 1000 / 60 / 60 - (24 * dnum); hnum = Math.floor(hours); 
		if(String(hnum).length ==1 ){hnum = "0" + hnum;} minutes = (now - grt ) / 1000 /60 - (24 * 60 * dnum) - (60 * hnum); 
		mnum = Math.floor(minutes); if(String(mnum).length ==1 ){mnum = "0" + mnum;} 
		seconds = (now - grt ) / 1000 - (24 * 60 * 60 * dnum) - (60 * 60 * hnum) - (60 * mnum); 
		snum = Math.round(seconds); if(String(snum).length ==1 ){snum = "0" + snum;} 
		document.getElementById("timeDate").innerHTML = "已安全运行 "+dnum+" 天 "; 
		document.getElementById("times").innerHTML = hnum + " 小时 " + mnum + " 分 " + snum + " 秒"; } setInterval("createtime()",250); </script>

</div>





        







        
      </div>
    </footer>

    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  


  











  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  

  
  
    <script type="text/javascript" src="/lib/canvas-nest/canvas-nest.min.js"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  










  <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src="//unpkg.com/valine/dist/Valine.min.js"></script>
  
  <script type="text/javascript">
    var GUEST = ['nick','mail','link'];
    var guest = 'nick,mail,link';
    guest = guest.split(',').filter(item=>{
      return GUEST.indexOf(item)>-1;
    });
    new Valine({
        el: '#comments' ,
        verify: true,
        notify: true,
        appId: 'yK4bP0J5SG9yN5Xo70kINyon-gzGzoHsz',
        appKey: 'pihr3aam43jDkFMNEqVNFsnC',
        placeholder: '在此处留言,请一并在右上方留下邮箱,这样当我回复您时，您能收到邮件通知,同时也可加q群：861016679 一起讨论',
        avatar:'mm',
        guest_info:guest,
        pageSize:'10' || 10,
    });
  </script>



  

  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    var isXml = true;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length === 0) {
      search_path = "search.xml";
    } else if (/json$/i.test(search_path)) {
      isXml = false;
    }
    var path = "/" + search_path;
    // monitor main search box;

    var onPopupClose = function (e) {
      $('.popup').hide();
      $('#local-search-input').val('');
      $('.search-result-list').remove();
      $('#no-result').remove();
      $(".local-search-pop-overlay").remove();
      $('body').css('overflow', '');
    }

    function proceedsearch() {
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay"></div>')
        .css('overflow', 'hidden');
      $('.search-popup-overlay').click(onPopupClose);
      $('.popup').toggle();
      var $localSearchInput = $('#local-search-input');
      $localSearchInput.attr("autocapitalize", "none");
      $localSearchInput.attr("autocorrect", "off");
      $localSearchInput.focus();
    }

    // search function;
    var searchFunc = function(path, search_id, content_id) {
      'use strict';

      // start loading animation
      $("body")
        .append('<div class="search-popup-overlay local-search-pop-overlay">' +
          '<div id="search-loading-icon">' +
          '<i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>' +
          '</div>' +
          '</div>')
        .css('overflow', 'hidden');
      $("#search-loading-icon").css('margin', '20% auto 0 auto').css('text-align', 'center');

      $.ajax({
        url: path,
        dataType: isXml ? "xml" : "json",
        async: true,
        success: function(res) {
          // get the contents from search data
          isfetched = true;
          $('.popup').detach().appendTo('.header-inner');
          var datas = isXml ? $("entry", res).map(function() {
            return {
              title: $("title", this).text(),
              content: $("content",this).text(),
              url: $("url" , this).text()
            };
          }).get() : res;
          var input = document.getElementById(search_id);
          var resultContent = document.getElementById(content_id);
          var inputEventFunction = function() {
            var searchText = input.value.trim().toLowerCase();
            var keywords = searchText.split(/[\s\-]+/);
            if (keywords.length > 1) {
              keywords.push(searchText);
            }
            var resultItems = [];
            if (searchText.length > 0) {
              // perform local searching
              datas.forEach(function(data) {
                var isMatch = false;
                var hitCount = 0;
                var searchTextCount = 0;
                var title = data.title.trim();
                var titleInLowerCase = title.toLowerCase();
                var content = data.content.trim().replace(/<[^>]+>/g,"");
                var contentInLowerCase = content.toLowerCase();
                var articleUrl = decodeURIComponent(data.url);
                var indexOfTitle = [];
                var indexOfContent = [];
                // only match articles with not empty titles
                if(title != '') {
                  keywords.forEach(function(keyword) {
                    function getIndexByWord(word, text, caseSensitive) {
                      var wordLen = word.length;
                      if (wordLen === 0) {
                        return [];
                      }
                      var startPosition = 0, position = [], index = [];
                      if (!caseSensitive) {
                        text = text.toLowerCase();
                        word = word.toLowerCase();
                      }
                      while ((position = text.indexOf(word, startPosition)) > -1) {
                        index.push({position: position, word: word});
                        startPosition = position + wordLen;
                      }
                      return index;
                    }

                    indexOfTitle = indexOfTitle.concat(getIndexByWord(keyword, titleInLowerCase, false));
                    indexOfContent = indexOfContent.concat(getIndexByWord(keyword, contentInLowerCase, false));
                  });
                  if (indexOfTitle.length > 0 || indexOfContent.length > 0) {
                    isMatch = true;
                    hitCount = indexOfTitle.length + indexOfContent.length;
                  }
                }

                // show search results

                if (isMatch) {
                  // sort index by position of keyword

                  [indexOfTitle, indexOfContent].forEach(function (index) {
                    index.sort(function (itemLeft, itemRight) {
                      if (itemRight.position !== itemLeft.position) {
                        return itemRight.position - itemLeft.position;
                      } else {
                        return itemLeft.word.length - itemRight.word.length;
                      }
                    });
                  });

                  // merge hits into slices

                  function mergeIntoSlice(text, start, end, index) {
                    var item = index[index.length - 1];
                    var position = item.position;
                    var word = item.word;
                    var hits = [];
                    var searchTextCountInSlice = 0;
                    while (position + word.length <= end && index.length != 0) {
                      if (word === searchText) {
                        searchTextCountInSlice++;
                      }
                      hits.push({position: position, length: word.length});
                      var wordEnd = position + word.length;

                      // move to next position of hit

                      index.pop();
                      while (index.length != 0) {
                        item = index[index.length - 1];
                        position = item.position;
                        word = item.word;
                        if (wordEnd > position) {
                          index.pop();
                        } else {
                          break;
                        }
                      }
                    }
                    searchTextCount += searchTextCountInSlice;
                    return {
                      hits: hits,
                      start: start,
                      end: end,
                      searchTextCount: searchTextCountInSlice
                    };
                  }

                  var slicesOfTitle = [];
                  if (indexOfTitle.length != 0) {
                    slicesOfTitle.push(mergeIntoSlice(title, 0, title.length, indexOfTitle));
                  }

                  var slicesOfContent = [];
                  while (indexOfContent.length != 0) {
                    var item = indexOfContent[indexOfContent.length - 1];
                    var position = item.position;
                    var word = item.word;
                    // cut out 100 characters
                    var start = position - 20;
                    var end = position + 80;
                    if(start < 0){
                      start = 0;
                    }
                    if (end < position + word.length) {
                      end = position + word.length;
                    }
                    if(end > content.length){
                      end = content.length;
                    }
                    slicesOfContent.push(mergeIntoSlice(content, start, end, indexOfContent));
                  }

                  // sort slices in content by search text's count and hits' count

                  slicesOfContent.sort(function (sliceLeft, sliceRight) {
                    if (sliceLeft.searchTextCount !== sliceRight.searchTextCount) {
                      return sliceRight.searchTextCount - sliceLeft.searchTextCount;
                    } else if (sliceLeft.hits.length !== sliceRight.hits.length) {
                      return sliceRight.hits.length - sliceLeft.hits.length;
                    } else {
                      return sliceLeft.start - sliceRight.start;
                    }
                  });

                  // select top N slices in content

                  var upperBound = parseInt('1');
                  if (upperBound >= 0) {
                    slicesOfContent = slicesOfContent.slice(0, upperBound);
                  }

                  // highlight title and content

                  function highlightKeyword(text, slice) {
                    var result = '';
                    var prevEnd = slice.start;
                    slice.hits.forEach(function (hit) {
                      result += text.substring(prevEnd, hit.position);
                      var end = hit.position + hit.length;
                      result += '<b class="search-keyword">' + text.substring(hit.position, end) + '</b>';
                      prevEnd = end;
                    });
                    result += text.substring(prevEnd, slice.end);
                    return result;
                  }

                  var resultItem = '';

                  if (slicesOfTitle.length != 0) {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + highlightKeyword(title, slicesOfTitle[0]) + "</a>";
                  } else {
                    resultItem += "<li><a href='" + articleUrl + "' class='search-result-title'>" + title + "</a>";
                  }

                  slicesOfContent.forEach(function (slice) {
                    resultItem += "<a href='" + articleUrl + "'>" +
                      "<p class=\"search-result\">" + highlightKeyword(content, slice) +
                      "...</p>" + "</a>";
                  });

                  resultItem += "</li>";
                  resultItems.push({
                    item: resultItem,
                    searchTextCount: searchTextCount,
                    hitCount: hitCount,
                    id: resultItems.length
                  });
                }
              })
            };
            if (keywords.length === 1 && keywords[0] === "") {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>'
            } else if (resultItems.length === 0) {
              resultContent.innerHTML = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>'
            } else {
              resultItems.sort(function (resultLeft, resultRight) {
                if (resultLeft.searchTextCount !== resultRight.searchTextCount) {
                  return resultRight.searchTextCount - resultLeft.searchTextCount;
                } else if (resultLeft.hitCount !== resultRight.hitCount) {
                  return resultRight.hitCount - resultLeft.hitCount;
                } else {
                  return resultRight.id - resultLeft.id;
                }
              });
              var searchResultList = '<ul class=\"search-result-list\">';
              resultItems.forEach(function (result) {
                searchResultList += result.item;
              })
              searchResultList += "</ul>";
              resultContent.innerHTML = searchResultList;
            }
          }

          if ('auto' === 'auto') {
            input.addEventListener('input', inputEventFunction);
          } else {
            $('.search-icon').click(inputEventFunction);
            input.addEventListener('keypress', function (event) {
              if (event.keyCode === 13) {
                inputEventFunction();
              }
            });
          }

          // remove loading animation
          $(".local-search-pop-overlay").remove();
          $('body').css('overflow', '');

          proceedsearch();
        }
      });
    }

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched === false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };
    });

    $('.popup-btn-close').click(onPopupClose);
    $('.popup').click(function(e){
      e.stopPropagation();
    });
    $(document).on('keyup', function (event) {
      var shouldDismissSearchPopup = event.which === 27 &&
        $('.search-popup').is(':visible');
      if (shouldDismissSearchPopup) {
        onPopupClose();
      }
    });
  </script>





  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.4.js"></script>
  <script>AV.initialize("yK4bP0J5SG9yN5Xo70kINyon-gzGzoHsz", "pihr3aam43jDkFMNEqVNFsnC");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

  

  
  
  
  <link rel="stylesheet" href="/lib/needsharebutton/needsharebutton.css">

  
  
  <script src="/lib/needsharebutton/needsharebutton.js"></script>

  <script>
    
      pbOptions = {};
      
          pbOptions.iconStyle = "box";
      
          pbOptions.boxForm = "horizontal";
      
          pbOptions.position = "bottomCenter";
      
          pbOptions.networks = "Weibo,Wechat,Douban,QQZone,Twitter,Facebook";
      
      new needShareButton('#needsharebutton-postbottom', pbOptions);
    
    
  </script>

  

  

  

  

<script src="/live2dw/lib/L2Dwidget.min.js?0c58a1486de42ac6cc1c59c7d98ae887"></script><script>L2Dwidget.init({"model":{"scale":1,"hHeadPos":0.5,"vHeadPos":0.618},"display":{"superSample":2,"width":150,"height":300,"position":"right","hOffset":0,"vOffset":-20},"mobile":{"show":true},"react":{"opacityDefault":0.5,"opacityOnHover":0.2},"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/","tagMode":false});</script></body>
</html>

<!-- 页面点击小红心 -->
<script type="text/javascript" src="/js/src/love.js"></script>

